package com.fulihui.systemcore.dal.mapper;

import com.fulihui.systemcore.dal.dataobj.SysColumn;
import com.fulihui.systemcore.dal.dataobj.SysColumnExample;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface SysColumnMapper {
    int countByExample(SysColumnExample example);

    int deleteByExample(SysColumnExample example);

    @Delete({
        "delete from sys_column",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into sys_column (id, parent_id, ",
        "level, name, img, ",
        "url, sort, status, ",
        "start_date, stop_date, ",
        "create_date, update_date)",
        "values (#{id,jdbcType=BIGINT}, #{parentId,jdbcType=BIGINT}, ",
        "#{level,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{img,jdbcType=VARCHAR}, ",
        "#{url,jdbcType=VARCHAR}, #{sort,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, ",
        "#{startDate,jdbcType=TIMESTAMP}, #{stopDate,jdbcType=TIMESTAMP}, ",
        "#{createDate,jdbcType=TIMESTAMP}, #{updateDate,jdbcType=TIMESTAMP})"
    })
    int insert(SysColumn record);

    int insertSelective(SysColumn record);

    List<SysColumn> selectByExample(SysColumnExample example);


    List<SysColumn> query(SysColumn record);

    @Select({
        "select",
        "id, parent_id, level, name, img, url, sort, status, start_date, stop_date, create_date, key_name, ",
        "update_date",
        "from sys_column",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    SysColumn selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") SysColumn record,
                                 @Param("example") SysColumnExample example);

    int updateByExample(@Param("record") SysColumn record,
                        @Param("example") SysColumnExample example);

    int updateByPrimaryKeySelective(SysColumn record);

    @Update({
        "update sys_column",
        "set parent_id = #{parentId,jdbcType=BIGINT},",
          "level = #{level,jdbcType=BIGINT},",
          "name = #{name,jdbcType=VARCHAR},",
          "img = #{img,jdbcType=VARCHAR},",
          "url = #{url,jdbcType=VARCHAR},",
          "sort = #{sort,jdbcType=BIGINT},",
          "status = #{status,jdbcType=VARCHAR},",
          "start_date = #{startDate,jdbcType=TIMESTAMP},",
          "stop_date = #{stopDate,jdbcType=TIMESTAMP},",
          "create_date = #{createDate,jdbcType=TIMESTAMP},",
          "update_date = #{updateDate,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(SysColumn record);
}